#!/usr/local/bin/python3
# -*- coding: UTF-8 -*-
"""
@author:apple
@file:MetaClassDemo01.py
@time:2021/09/16
"""

# class TopMeta(type):
#     ...
#
#     def __call__(self, *args, **kwargs):
#         print(self)
#         obj = self.__new__(self)
#         self.__init__(obj, *args, **kwargs)
#         return obj

class MyMeta(type):
    ...
    # def __init__(self,class_name,class_super,class_dict):
    #     """
    #     这里控制 Person这个类对象的初始化
    #     """
    #     print(self)
    #     print(class_name,class_super,class_dict)
    #     super().__init__(class_name,class_super,class_dict)

    def __call__(self, *args, **kwargs):
        """
        self 为 Person类
        """
        obj = self.__new__(self)
        self.__init__(obj, *args,**kwargs)
        return obj

class A:
    ...

class Person(A,metaclass=MyMeta):
    ...

    def __init__(self, name, age):
        self.name = name
        self.age = age

    def __call__(self, *args, **kwargs):
        ...
        print('111')

if __name__ == '__main__':
    pass
    person = Person(name='zhangsan',age=21)
    person()